#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------
# -- Editor Md
# -- 
# ****************************
# Author: lmay.Zhou
# Blog: www.lmaye.com
# @email lmay@lmaye.com
# Date: 2018年4月8日 23:15:56
# ----------------------------------------------------------
from flask import render_template
from core.app import app
from core.forms.editor_forms import EditorForm
from core.utils.file_utils import write_file
from core.constant.sys_enum import SysEnum


@app.route("/editor", methods=["GET", "POST"])
def editor():
    form = EditorForm()
    if form.validate_on_submit():
        editor_txt = form.editor_txt.data
        write_file("test", ".md", editor_txt, SysEnum.TEMP_PATH.value)
    return render_template("editor/editor.html", title="Editor Md", form=form)
